﻿namespace MicroCloud.Identity.Database
{
    /// <summary>
    /// 角色声明信息数据实体映射配置
    /// </summary>
    public class RoleClaimConfiguration : EntityTypeConfigurationBase<RoleClaim, long>
    {
        /// <summary>
        /// 重写以实现实体类型各个属性的数据库配置
        /// </summary>
        /// <param name="builder">实体类型创建器</param>
        public override void Configuration(EntityTypeBuilder<RoleClaim> builder)
        {
            //builder.HasOne(rc => rc.Role).WithMany(r => r.RoleClaims).HasForeignKey(m => m.RoleId).HasConstraintName("FK_RoleClaim_RoleId").IsRequired();
            builder.HasOne(rc => rc.Role).WithMany(r => r.RoleClaims).HasForeignKey(m => m.RoleId).SetForeignKey("RoleId");

            builder.HasQueryFilter(o => o.Role.DeletedTime == null);

            ConfigurationAppend(builder);
        }

    }
}
